<template>
  <div class="robotMessage" @click="handelClick" v-html="msg"></div>
</template>

<script>
/** vue */
import ChatMixin from '@src/modules/im/ChatMixin/index.js';
import { openAccurateTab } from '@src/util/platform'
import { PageRoutesTypeEnum } from 'pub-bbx-global/pageType/dist/enum/PageRoutesEnum'
export default {
  name: 'robot-message',
  mixins: [ChatMixin],
  props: {
    info: {
      type: Object,
      default: () => ({}),
    },
  },
  data() {
    return {};
  },
  computed: {
    msg() {
      return this.compatibleFieldByCustomExts(this.info, 'msg');
    },
  },
  methods: {
    handelClick(e) {
      let target = e.target;
      if (!target) return;
      let isKnowledge = target.getAttribute('data-page') == 'KnowledgeBase';
      let fromId = window.frameElement.getAttribute('id');
      if (isKnowledge) {
        let id = target.getAttribute('data-id');
        openAccurateTab({
          fromId,
          key:id,
          params:`wikiId=${id}`,
          type:PageRoutesTypeEnum.PageWikiDetail
        });
        return;
      }
    },
  },
};
</script>

<style scoped lang="scss">
.robotMessage {
  max-width: 100%;
  ::v-deep .wiki-quote-tag {
    color: $color-primary;
    cursor: pointer;
  }
}
</style>
